package com.yunfeisoft.business.model;

import com.yunfeisoft.common.base.BaseModel;
import com.yunfeisoft.common.sql.record.TransientField;
import com.yunfeisoft.common.utils.DateUtils;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

/**
 * ClassName: Elder
 * Description: 老人入院登记表
 *
 * @Author: Jackie liu
 * Date: 2020-01-13
 */
@Entity
@Table(name = "TT_ELDER")
public class Elder extends BaseModel implements Serializable {

    /**
     * Field serialVersionUID: 序列号
     */
    private static final long serialVersionUID = 1L;

    /**
     * 姓名
     */
    @Column
    private String name;

    /**
     * 入院号
     */
    @Column
    private String code;

    /**
     * 房间ID
     */
    @Column
    private String roomId;

    /**
     * 床位号
     */
    @Column
    private String bedNum;

    /**
     * 入住日期
     */
    @Column
    private Date checkInDate;

    /**
     * 所属组织机构
     */
    @Column
    private String orgId;

    /**
     * 性别
     */
    @Column
    private String sex;

    /**
     * 出生年月
     */
    @Column
    private String birthDate;

    /**
     * 护理等级
     */
    @Column
    private Integer nursingLevel;

    /**
     * 优惠终止时间
     */
    @Column
    private Date discountStopDate;

    /**
     * 文化程度(字典项)
     */
    @Column
    private String eduDegree;

    /**
     * 政治面貌
     */
    @Column
    private String politicalOutlook;

    /**
     * 籍贯
     */
    @Column
    private String nativePlace;

    /**
     * 民族
     */
    @Column
    private String nation;

    /**
     * 曾从事职业
     */
    @Column
    private String profession;

    /**
     * 经济来源
     */
    @Column
    private String incomeSource;

    /**
     * 婚姻状况(字典项)
     */
    @Column
    private String maritalStatus;

    @TransientField
    private String maritalStatusStr;

    /**
     * 宗教信仰
     */
    @Column
    private String faith;

    /**
     * 主要病史/药物过敏
     */
    @Column
    private String medicalHistory;

    /**
     * 社保卡号
     */
    @Column
    private String socialCardNum;

    /**
     * 身份证号
     */
    @Column
    private String idcard;

    /**
     * 户籍地址
     */
    @Column
    private String address;

    /**
     * 生日
     */
    @Column
    private String birthday;

    /**
     * 生活习惯、兴趣爱好
     */
    @Column
    private String habit;

    /**
     * 习惯就诊医院
     */
    @Column
    private String hospital;

    /**
     * 第一联系人
     */
    @Column
    private String contactName1;

    /**
     * 第一联系人电话
     */
    @Column
    private String contactPhone1;

    /**
     * 第二联系人
     */
    @Column
    private String contactName2;

    /**
     * 第二联系人电话
     */
    @Column
    private String contactPhone2;

    /**
     * 第三联系人
     */
    @Column
    private String contactName3;

    /**
     * 第三联系人电话
     */
    @Column
    private String contactPhone3;

    /**
     * 备注
     */
    @Column
    private String remark;

    /**
     * 状态
     */
    @Column
    private Integer status;

    /**
     * 审批状态
     */
    @TransientField
    private Integer approvalStatus;

    /**
     * 审批时间
     */
    @TransientField
    private Date approvalCreateTime;

    @TransientField
    private String eduDegreeStr;
    @TransientField
    private String orgName;

    public String getCheckInDateStr() {
        if (checkInDate == null) {
            return null;
        }
        return DateUtils.dateToString(checkInDate);
    }

    public String getSexStr () {
        if (StringUtils.isBlank(sex)) {
            return null;
        }
        switch (sex) {
            case "1":
                return "男";
            case "2":
                return "女";
            case "3":
                return "未知";
            default:
                return "";
        }
    }

    public String getEduDegreeStr() {
        return eduDegreeStr;
    }

    public void setEduDegreeStr(String eduDegreeStr) {
        this.eduDegreeStr = eduDegreeStr;
    }

    public String getMaritalStatusStr() {
        return maritalStatusStr;
    }

    public void setMaritalStatusStr(String maritalStatusStr) {
        this.maritalStatusStr = maritalStatusStr;
    }

    public Date getApprovalCreateTime() {
        return approvalCreateTime;
    }

    public String getApprovalCreateTimeStr() {
        if (approvalCreateTime == null) {
            return null;
        }
        return DateUtils.dateToString(approvalCreateTime);
    }

    public void setApprovalCreateTime(Date approvalCreateTime) {
        this.approvalCreateTime = approvalCreateTime;
    }

    public String getApprovalStatusStr() {
        if (approvalStatus == null) {
            return null;
        }
        return ElderApprovalResult.ApprovalStatusEnum.valueOf(approvalStatus);
    }

    public Integer getApprovalStatus() {
        return approvalStatus;
    }

    public void setApprovalStatus(Integer approvalStatus) {
        this.approvalStatus = approvalStatus;
    }

    public String getStatusStr() {
        return ElderStatusEnum.valueOf(status);
    }

    public String getNursingLevelStr() {
        if (nursingLevel == null) {
            return null;
        }
        return ElderNursingLevelEnum.valueOf(Integer.valueOf(nursingLevel));
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getRoomId() {
        return roomId;
    }

    public void setRoomId(String roomId) {
        this.roomId = roomId;
    }

    public String getBedNum() {
        return bedNum;
    }

    public void setBedNum(String bedNum) {
        this.bedNum = bedNum;
    }

    public Date getCheckInDate() {
        return checkInDate;
    }

    public void setCheckInDate(Date checkInDate) {
        this.checkInDate = checkInDate;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getBirthDate() {
        return birthDate;
    }

    public void setBirthDate(String birthDate) {
        this.birthDate = birthDate;
    }

    public Integer getNursingLevel() {
        return nursingLevel;
    }

    public void setNursingLevel(Integer nursingLevel) {
        this.nursingLevel = nursingLevel;
    }

    public Date getDiscountStopDate() {
        return discountStopDate;
    }

    public void setDiscountStopDate(Date discountStopDate) {
        this.discountStopDate = discountStopDate;
    }

    public String getEduDegree() {
        return eduDegree;
    }

    public void setEduDegree(String eduDegree) {
        this.eduDegree = eduDegree;
    }

    public String getPoliticalOutlook() {
        return politicalOutlook;
    }

    public void setPoliticalOutlook(String politicalOutlook) {
        this.politicalOutlook = politicalOutlook;
    }

    public String getNativePlace() {
        return nativePlace;
    }

    public void setNativePlace(String nativePlace) {
        this.nativePlace = nativePlace;
    }

    public String getNation() {
        return nation;
    }

    public void setNation(String nation) {
        this.nation = nation;
    }

    public String getProfession() {
        return profession;
    }

    public void setProfession(String profession) {
        this.profession = profession;
    }

    public String getIncomeSource() {
        return incomeSource;
    }

    public void setIncomeSource(String incomeSource) {
        this.incomeSource = incomeSource;
    }

    public String getMaritalStatus() {
        return maritalStatus;
    }

    public void setMaritalStatus(String maritalStatus) {
        this.maritalStatus = maritalStatus;
    }

    public String getFaith() {
        return faith;
    }

    public void setFaith(String faith) {
        this.faith = faith;
    }

    public String getMedicalHistory() {
        return medicalHistory;
    }

    public void setMedicalHistory(String medicalHistory) {
        this.medicalHistory = medicalHistory;
    }

    public String getSocialCardNum() {
        return socialCardNum;
    }

    public void setSocialCardNum(String socialCardNum) {
        this.socialCardNum = socialCardNum;
    }

    public String getIdcard() {
        return idcard;
    }

    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    public String getHabit() {
        return habit;
    }

    public void setHabit(String habit) {
        this.habit = habit;
    }

    public String getHospital() {
        return hospital;
    }

    public void setHospital(String hospital) {
        this.hospital = hospital;
    }

    public String getContactName1() {
        return contactName1;
    }

    public void setContactName1(String contactName1) {
        this.contactName1 = contactName1;
    }

    public String getContactPhone1() {
        return contactPhone1;
    }

    public void setContactPhone1(String contactPhone1) {
        this.contactPhone1 = contactPhone1;
    }

    public String getContactName2() {
        return contactName2;
    }

    public void setContactName2(String contactName2) {
        this.contactName2 = contactName2;
    }

    public String getContactPhone2() {
        return contactPhone2;
    }

    public void setContactPhone2(String contactPhone2) {
        this.contactPhone2 = contactPhone2;
    }

    public String getContactName3() {
        return contactName3;
    }

    public void setContactName3(String contactName3) {
        this.contactName3 = contactName3;
    }

    public String getContactPhone3() {
        return contactPhone3;
    }

    public void setContactPhone3(String contactPhone3) {
        this.contactPhone3 = contactPhone3;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getOrgId() {
        return orgId;
    }

    public void setOrgId(String orgId) {
        this.orgId = orgId;
    }

    public String getOrgName() {
        return orgName;
    }

    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }

    public enum ElderStatusEnum {
        REGISTER(1, "入院登记"),
        DOCTOR_ACCEPT(2, "医生评估通过"),
        DOCTOR_REJECT(3, "医生评估驳回"),
        NURSE_ACCEPT(4, "护理评估通过"),
        NURSE_REJECT(5, "护理评估拒绝"),
        CHECK_IN(6, "正式入住"),
        CONTRACT_ACCEPT(7, "院办审批通过"),
        CONTRACT_REJECT(8, "院办审批拒绝"),
        HOSPITAL_OFFICE_ARCHIVE(9, "院办存档");

        private int value;
        private String label;

        private ElderStatusEnum(int value, String label) {
            this.value = value;
            this.label = label;
        }

        public static String valueOf(Integer value) {
            if (value == null) {
                return null;
            }
            ElderStatusEnum[] values = ElderStatusEnum.values();
            for (ElderStatusEnum loop : values) {
                if (value == loop.getValue()) {
                    return loop.getLabel();
                }
            }
            return null;
        }

        public Integer getValue() {
            return value;
        }

        public String getLabel() {
            return label;
        }
    }

    public enum ElderNursingLevelEnum {
        SELF_CARE(1, "自理"),
        BAN_ONE(2, "半护一级"),
        BAN_TWO(3, "半护二级"),
        ALL_ONE(4, "全护一级"),
        ALL_TWO(5, "全护二级"),
        ALL_THREE(6, "全护三级");

        private int value;
        private String label;

        private ElderNursingLevelEnum(int value, String label) {
            this.value = value;
            this.label = label;
        }

        public static String valueOf(Integer value) {
            if (value == null) {
                return null;
            }
            ElderNursingLevelEnum[] values = ElderNursingLevelEnum.values();
            for (ElderNursingLevelEnum loop : values) {
                if (value == loop.getValue()) {
                    return loop.getLabel();
                }
            }
            return null;
        }

        public Integer getValue() {
            return value;
        }

        public String getLabel() {
            return label;
        }

    }
}